/*
 * Copyright (c) 2019. Dxxld@qq.com. All rights reserved.
 */

package com.wauil.keenote.algorithm;

/**
 * @Description:
 * @Author: kee
 * @Email: dxxld@qq.com
 * @Date: 2019/12/20 11:54
 * @Version: 1.0
 */
public class QuickSort {
    public void sort(int[] array, int start, int end) {
        if (start >= end) {
            return;
        }
        int base = array[start];
        int left = start + 1;
        int right = end;
        while (left < right) {
            while (array[right] > base) {
                right--;
            }
            while (right > left && array[left] < base) {
                left++;
            }
            if (left < right) {
                int temp = array[left];
                array[left] = array[right];
                array[right] = temp;
            }
        }
        array[start] = array[left];
        array[left] = base;
        sort(array,start,left-1);
        sort(array, left + 1, end);
    }
}
